#!/bin/bash

# EF Service    connect service for EFDemo
#
# chkconfig: 2345 80 30
# description: connect service for EFDemo
# processname: ef_service


# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

APP_PATH=/srv/ef_service
EXEC=ef_service
DAEMON=$APP_PATH/$EXEC
OPTIONS="-c=$APP_PATH/config"
LOGFILE=$APP_PATH/ef_service.log

if [ -f /etc/sysconfig/ef_service ];then
        . /etc/sysconfig/ef_service
fi

prog='EF Service'

start() {
	# Check that networking is up.
	[ "$NETWORKING" = "no" ] && exit 1
	
        echo -n $"Starting $prog: "
	daemon --check $EXEC nohup $DAEMON $OPTIONS < /dev/null > $LOGFILE &
	RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$EXEC
	return $RETVAL
}
	
stop() {
        echo -n $"Shutting down $prog: "
	killproc $EXEC
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$EXEC
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
        ;;
  stop)
	stop
        ;;
  status)
	status $EXEC
	RETVAL=$?
	;;
  restart|reload)
	stop
	start
	RETVAL=$?
	;;
  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        RETVAL=3
esac

exit $RETVAL
